<%--
  Created by IntelliJ IDEA.
  User: Yy
  Date: 2022/5/29
  Time: 15:58
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
    <script>
        layui.use(['table','util','jquery','layer','form'],function () {
            var table = layui.table, util = layui.util, $ = layui.jquery, layer = layui.layer, form = layui.form;
            //分班
            $("#fb_btn").click(function(){
                var huorId=$("#cid").val();
                // alert(clid);
                var checkStatus = table.checkStatus('title');
                var datas = checkStatus.data;
                var ids = [];
                // var clazz = $("#clazz").val();
                for(var i=0;i<datas.length;i++){
                    ids[i]=datas[i].stuId;
                }
                // alert(ids);
                if(ids.length!=0){
                    $.ajax({
                        url:"${pageContext.request.contextPath}/stu/fpstuss",
                        data:{
                            "ids":ids,
                            "huorId":huorId
                        },
                        dataType:"json",
                        type:"post",
                        traditional:true,//防止深度序列化
                        cache:false,
                        async:false,
                        success:function(data){
                            layer.msg(data.msg);
                        }
                    });
                    table.reload('titleStu',{
                        url:'${pageContext.request.contextPath}/stu/ssfp'
                    });
                    table.reload('title',{
                        url:'${pageContext.request.contextPath}/stu/ssfpstu'
                    });
                }
            })
        });
    </script>
</head>
<body>
    <table class="layui-table" id="titleStu" lay-filter="demo" lay-size="sm"
                   lay-data="{url:'${pageContext.request.contextPath}/stu/ssfp',page:true,id:'titleStu'}"
    >
        <thead>
        <tr>
            <th lay-data="{field:'huorId',sort:true}">宿舍编号</th>
            <th lay-data="{field:'huorName',sort:true}">宿舍名字</th>
            <th lay-data="{field:'addr',sort:true}">地址</th>
            <th lay-data="{field:'count',sort:true}">宿舍人数</th>
            <th lay-data="{field:'floorName',sort:true}">楼栋</th>
            <th lay-data="{field:'numberBeds',sort:true}">床位数</th>
            <%--  <th lay-data="{field:'huoeIddsc',sort:true}"></th>--%>
<%--            <th lay-data="{toolbar:'#tools',width:150,align:'center',fixed:'right'}">操作</th>--%>
        </tr>
        </thead>
    </table>
    <form class="layui-form" >
        <div class="layui-inline">宿舍:</div>
        <div class="layui-inline">
            <select name="clazz" id="cid">
                <c:forEach items="${stuh}" var="e">
                    <option value="${e.huorId}">${e.huorName}</option>
                </c:forEach>
            </select>
        </div>
<%--        <div class="layui-form-item">--%>
            <button id="fb_btn" type="button" lay-submit lay-filter="fb_btn" class="layui-btn layui-btn-normal">
                分配
            </button>
<%--        </div>--%>
    </form>
    <h2>未分宿舍学生</h2>
    <table class="layui-table" id="title" lay-filter="demo" lay-size="sm"
           lay-data="{url:'${pageContext.request.contextPath}/stu/ssfpstu',page:true,id:'title'}"
    >
        <thead>
        <tr>
            <th lay-data="{type:'checkbox'}"></th>
            <th lay-data="{field:'stuname',sort:true}">学生名字</th>
            <th lay-data="{field:'sex',sort:true}">性别</th>
<%--            <th lay-data="{field:'card',sort:true}">身份证</th>--%>
            <th lay-data="{field:'phone',sort:true}">手机号</th>
            <th lay-data="{field:'clazz',sort:true}">班级</th>
<%--            <th lay-data="{field:'nation',sort:true}"></th>--%>
            <%--  <th lay-data="{field:'huoeIddsc',sort:true}"></th>--%>
<%--        <th lay-data="{toolbar:'#tools',width:150,align:'center',fixed:'right'}">操作</th>--%>
        </tr>
        </thead>
    </table>
</body>
</html>
